#ifndef ICONPROVIDER_H
#define ICONPROVIDER_H

#include <QObject>
#include <QMap>
#include <QIcon>
#include <QFileInfo>


class IconProvider : public QObject
{
    Q_OBJECT
public:
    enum IconRole
    {
        Folder,
        ResourceGroup,
        FormGroup,
        File,
        PyModule
    };

    static IconProvider* instance();

    QIcon icon(IconRole role);
    QIcon icon(const QString & iconName);
    QIcon icon(const QFileInfo & info);
private slots:
    void removeIcons();
private:
    IconProvider();
    IconProvider(const IconProvider &);
    IconProvider& operator=(const IconProvider &);
    static IconProvider* _instance;

    void createIcon(QIcon & dest, const QIcon & src, QSize size, const QImage & srcPixmap, QIcon::Mode mode, QIcon::State state);
    QIcon createCompositeIcon(const QIcon proto, const QImage & img);
    QMap<QString, QIcon> _cache;
};

Q_DECLARE_INTERFACE(IconProvider, "test")

#endif // ICONPROVIDER_H
